"=" return value

Funny thing happened on the way to the Forum:

  • int i = 1
  • int j
  • int k = (j=i+1)+1
  • print i "\t" j "\t" k "\n"

I must be a dinosaur, never seen anything like that before.

Have been looking at the doors.exe definitions of functions, and aways wondered how an assignment statement itself could return a value.  Not sure I like putting an assignment on the right side of an assignment however; just begging for confusion.

-Louie

 


llandale - Fri Jun 27 10:21:42 EDT 2014

Re: "=" return value
adevicq - Fri Jun 27 10:26:36 EDT 2014

Hi

If I remember well this is conform to the C language grammar.

Alain

Re: "=" return value
llandale - Fri Jun 27 11:06:08 EDT 2014

adevicq - Fri Jun 27 10:26:36 EDT 2014

Hi

If I remember well this is conform to the C language grammar.

Alain

"C" wasn't around when I graduated 1933.  Whatever.

Re: "=" return value
Wolfgang Uhr - Mon Jun 30 02:06:51 EDT 2014

Hi Louie

That was one of the worst things you could do with c.

 

int i1;
int i2;
int i3;
Date dt1;

dt1 = dateOf(i1 = i2 =  i3 = 15);

print i1 "\n";
print i2 "\n";
print i3 "\n";

print dt1;

As you can see above, you can create the most curios code snippets using this technique.